/*************************************************************************
	> File Name: oj-398_horse_bfs.cpp
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2020年11月18日 星期三 18时39分45秒
 ************************************************************************/

#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

struct node {
    int x, y, step;
};

int n, m, sx, sy, mmap[405][405];
int dir[8][2] = {
    1, 2,
    1, -2,
    -1, 2,
    -1, -2,
    2, 1,
    2, -1,
    -2, 1,
    -2, -1
};
int main() {
    //初始化-1方便判断
    memset(mmap, -1, sizeof(mmap));
    cin >> n >> m >> sx >> sy;
    mmap[sx][sy] = 0;
    queue<node> que;
    que.push((node){sx, sy, 0});
    while (!que.empty()) {
        node temp = que.front();
        que.pop();
        for (int i = 0; i < 8; ++i) {
            int x = temp.x + dir[i][0];
            int y = temp.y + dir[i][1];
            //判断边界
            if (x < 1 || y < 1 || x > n || y > m || mmap[x][y] != -1) {
                continue;
            }
            mmap[x][y] = temp.step + 1;
            que.push((node){x, y, mmap[x][y]});
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (j != 1) {
                cout << " ";
            }
            cout << mmap[i][j];
        }
        cout << endl;
    }
    return 0;
}
